08.b - GitHub-App-Configuration
Relevant source files
This document provides a comprehensive guide to creating and configuring the GitHub App required for godeep.wiki to authenticate with GitHub and access customer repositories. The GitHub App serves as the authentication mechanism that enables users to grant repository access during the payment-to-installation workflow.
For information about how the GitHub App integrates with the OAuth flow, see GitHub OAuth Initiation and OAuth Callback Handler. For details on environment variables required after app creation, see Environment Variables.
GitHub App Purpose and ArchitectureLink copied!
The GitHub App (godeepwiki-github-integration) provides the authentication infrastructure for the godeep.wiki system. It enables two distinct authentication patterns:
- User OAuth Authentication: Customers authenticate during the payment flow to grant repository access
- Installation Token Generation: The owner generates installation access tokens to clone customer repositories
The GitHub App is distinct from a GitHub OAuth App. While both support user authentication, a GitHub App provides installation-based access that allows the owner to access repositories on behalf of the installing user.
GitHub App Integration ArchitectureLink copied!
Sources: README.md L102-L156
app/api/auth/github/setup/route.ts L1-L67
Creating the GitHub AppLink copied!
Registration LocationLink copied!
GitHub Apps can be registered under either an organization or a personal account. The location determines the app's visibility and management structure.
| Account Type | Registration URL | Use Case |
|---|---|---|
| Organization | https://github.com/organizations/YOUR_ORG/settings/apps/new | Multi-user management, team access |
| Personal | https://github.com/settings/apps/new | Single-owner management, simpler setup |
For godeep.wiki, the app is registered under a personal account (Klaudioz) and managed at:
https://github.com/settings/apps/godeepwiki-github-integration
Sources: README.md L106-L108
Basic Configuration SettingsLink copied!
App IdentityLink copied!
The following table specifies the required basic configuration for the GitHub App:
| Setting | Value | Purpose |
|---|---|---|
| GitHub App name | GoDeep Wiki Integration or godeepwiki-github-integration | Unique identifier for the app |
| Description | See description template below | User-facing explanation of app purpose |
| Homepage URL | https://godeep.wiki | App landing page |
| Callback URL | https://godeep.wiki/api/auth/github/callback | OAuth redirect endpoint |
| Setup URL (optional) | https://godeep.wiki/api/auth/github/setup | Post-installation configuration |
Description TemplateLink copied!
GitHub provides a description field for users to understand the app's purpose. The recommended description emphasizes security best practices:
Allows users to share a repo to generate a deep documentation⚠️ Please select "Only select repositories" during installationfor security. Choose only the repo you want to document.
This description is stored in github-app-description.md L1-L47
with multiple length variants for character-limited fields.
URL Configuration MappingLink copied!
Sources: README.md L112-L118
github-app-description.md L1-L47
Permissions ConfigurationLink copied!
The GitHub App requires minimal read-only permissions to access repository contents and user metadata. This principle of least privilege minimizes security exposure.
Repository PermissionsLink copied!
| Permission | Access Level | Purpose |
|---|---|---|
| Contents | Read | Access repository files for documentation generation |
| Metadata | Read | Access repository name, description, visibility status |
Account PermissionsLink copied!
| Permission | Access Level | Purpose |
|---|---|---|
| Email addresses | Read | Identify customer for delivery correlation |
Permission Enforcement FlowLink copied!
The read-only permission model ensures that even if credentials are compromised, attackers cannot modify customer code. This aligns with the security principle documented in the high-level architecture diagrams.
Sources: README.md L130-L135
OAuth ConfigurationLink copied!
OAuth Settings ChecklistLink copied!
The GitHub App must enable OAuth to support user authentication during the GitHub connection flow. Configure the following settings:
| Setting | Value | Required |
|---|---|---|
| Request user authorization (OAuth) during installation | ✅ Enabled | Yes |
| Callback URL | https://godeep.wiki/api/auth/github/callback | Yes |
| OAuth Scopes | read:user user:email | Yes |
| Enable Device Flow | ✅ Enabled (optional) | No |
OAuth Flow and Code MappingLink copied!
The state parameter provides CSRF protection by ensuring the callback originated from the same session that initiated the OAuth flow. This is implemented in app/api/auth/github/route.ts
(state generation) and verified in app/api/auth/github/callback/route.ts
(state validation).
Sources: README.md L137-L140
app/api/auth/github/setup/route.ts L52-L62
Webhook ConfigurationLink copied!
While the system does not use GitHub App webhooks (it uses Stripe webhooks instead), the GitHub App configuration includes a webhook secret field that should be configured for future extensibility.
| Setting | Environment Variable | Purpose |
|---|---|---|
| Webhook URL | Not currently used | Future event notifications |
| Webhook Secret | GITHUB_WEBHOOK_SECRET | Signature verification for webhook payloads |
To generate a webhook secret:
# Generate a random secretopenssl rand -hex 32# Or use Node.jsnode -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
Store the generated secret in both the GitHub App settings and the .env file as GITHUB_WEBHOOK_SECRET.
Sources: .env.example L6
Repository Access RecommendationsLink copied!
Installation OptionsLink copied!
During GitHub App installation, users are presented with two options for repository access:
- All repositories - Grants access to all current and future repositories
- Only select repositories - Grants access only to specified repositories
The system strongly recommends users select "Only select repositories" for security and privacy reasons. This recommendation is communicated in:
- GitHub App description field
- User-facing documentation
- Installation prompts
Security RationaleLink copied!
The "Only select repositories" option is user-controlled, not enforced by the app developer. The GitHub App configuration cannot restrict this choice—it can only recommend best practices through documentation.
Sources: README.md L141-L145
github-app-description.md L8-L11
Obtaining GitHub App CredentialsLink copied!
After creating the GitHub App, you must obtain five credentials and store them as environment variables.
Credential Acquisition ProcessLink copied!
Credential Mapping TableLink copied!
| GitHub App Field | Environment Variable | Format | Usage |
|---|---|---|---|
| App ID | GITHUB_APP_ID | Numeric | JWT signing for installation tokens |
| Client ID | GITHUB_CLIENT_ID | Iv1.xxxxxxxxxxxxxxxx | OAuth flow initiation |
| Client Secret | GITHUB_CLIENT_SECRET | Alphanumeric string | Token exchange during OAuth callback |
| Private Key | GITHUB_PRIVATE_KEY | PEM format RSA key | JWT signing for installation tokens |
| App Slug | GITHUB_APP_SLUG | Lowercase with hyphens | OAuth redirect URL construction |
Private Key HandlingLink copied!
The private key is downloaded as a .pem file. To store it in the .env file:
# Read the private key filecat godeepwiki-github-integration.2024-01-01.private-key.pem# Copy the entire contents including header and footer# Example format:# -----BEGIN RSA PRIVATE KEY-----# MIIEpAIBAAKCAQEA...# ...multiple lines...# -----END RSA PRIVATE KEY-----# Store in .env with newlines preserved using \nGITHUB_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAK...\n-----END RSA PRIVATE KEY-----"
The private key is used by app/api/admin/generate-token/route.ts
to sign JWTs when generating installation access tokens.
Sources: README.md L146-L149
Environment Variable ConfigurationLink copied!
After obtaining credentials from the GitHub App settings, populate the following environment variables in your .env file:
# GitHub App IdentificationGITHUB_APP_SLUG=godeepwiki-github-integrationGITHUB_APP_ID=123456# OAuth Credentials (User Authentication)GITHUB_CLIENT_ID=Iv1.abcd1234567890abGITHUB_CLIENT_SECRET=abcd1234567890abcdef1234567890abcdef1234# Installation Token Credentials (Owner Authentication)GITHUB_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIEpAI...\n-----END RSA PRIVATE KEY-----"# Webhook Verification (Optional)GITHUB_WEBHOOK_SECRET=abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890
Variable Usage MappingLink copied!
Sources: .env.example L1-L6
Post-Creation VerificationLink copied!
After configuring the GitHub App, verify the setup using the following checklist:
Configuration Verification ChecklistLink copied!
| Component | Verification Method | Expected Result |
|---|---|---|
| App Slug | Visit https://github.com/apps/SLUG | App page loads without 404 |
| OAuth Callback | Test OAuth flow from landing page | Redirects to /thank-you after authorization |
| Permissions | Check app settings | Contents: Read, Metadata: Read, Email: Read |
| Environment Variables | Review .env file | All 5 GitHub variables populated |
| Private Key | Test token generation | JWT signs successfully without errors |
Testing the OAuth FlowLink copied!
To verify the complete OAuth configuration:
- Navigate to the landing page at
https://godeep.wiki - Complete the $10 payment via Stripe
- Click "Connect GitHub Account" on the success page
- Verify redirect to
https://github.com/apps/godeepwiki-github-integration/installations/new - Select a test repository and approve permissions
- Verify redirect to callback URL
/api/auth/github/callback - Check Vercel logs for successful token exchange
- Verify redirect to
/thank-youpage
If any step fails, consult the Troubleshooting
section in the README.
Sources: README.md L314-L367
Managing the GitHub AppLink copied!
Access URLsLink copied!
Once created, the GitHub App can be managed at:
| Context | URL Pattern | Example |
|---|---|---|
| Organization | https://github.com/organizations/{ORG}/settings/apps/{APP_SLUG} | https://github.com/organizations/godeep-wiki/settings/apps/godeepwiki-github-integration |
| Personal | https://github.com/settings/apps/{APP_SLUG} | https://github.com/settings/apps/godeepwiki-github-integration |
| Public Page | https://github.com/apps/{APP_SLUG} | https://github.com/apps/godeepwiki-github-integration |
Ongoing Management TasksLink copied!
Monitoring InstallationsLink copied!
GitHub provides an installations view showing all users who have installed the app. Access this at:
https://github.com/settings/apps/godeepwiki-github-integration/installations
This view displays:
- User/organization name
- Installation ID
- Repository access scope (all vs. selected)
- Installation date
- Suspension status
The installation ID shown here corresponds to the installation_id captured during the OAuth callback and used for generating installation access tokens.
Sources: README.md L151-L156
Security ConsiderationsLink copied!
Credential StorageLink copied!
All GitHub App credentials must be stored securely and never committed to version control:
- Store in
.envfile (included in.gitignore) - Configure in Vercel environment variables for production
- Never log credentials in application code
- Rotate credentials if compromised
Access Token LifespanLink copied!
The system implements two token types with different lifespans:
| Token Type | Lifespan | Purpose | Storage |
|---|---|---|---|
| User OAuth Token | 24 hours | Dashboard access for users | HTTP-only cookie |
| Installation Access Token | 1 hour | Repository cloning by owner | Temporary (not stored) |
The 1-hour installation token lifespan minimizes exposure if credentials are intercepted during the automation pipeline execution.
Read-Only Access ModelLink copied!
The GitHub App's read-only permissions ensure that even with valid credentials, the system cannot:
- Modify repository contents
- Delete files or repositories
- Create branches or commits
- Modify repository settings
- Access GitHub Actions secrets
This defense-in-depth approach limits the blast radius of credential compromise.
Sources: README.md L394-L406
Diagram 3 from high-level architecture
TroubleshootingLink copied!
Common Configuration IssuesLink copied!
404 Error: GitHub App Not Found
Symptom: Redirect to GitHub App installation returns 404
Cause: GITHUB_APP_SLUG doesn't match the actual app slug
Solution:
# Verify the slug matches the GitHub App URL# Correct: godeepwiki-github-integration# Incorrect: godeep-wiki or GoDeepWiki (case-sensitive)echo $GITHUB_APP_SLUG# Should output: godeepwiki-github-integration# The slug is part of the GitHub App URL:# https://github.com/apps/godeepwiki-github-integration# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# This is your GITHUB_APP_SLUG
Invalid Client Error
Symptom: OAuth flow fails with "Invalid client" error
Cause: Mismatch between GITHUB_CLIENT_ID and the app's actual client ID
Solution:
- Navigate to GitHub App settings
- Locate the "Client ID" field in the OAuth credentials section
- Copy the exact value (format:
Iv1.xxxxxxxxxxxxxxxx) - Update
.envfile - Redeploy application
Private Key Format Error
Symptom: Token generation fails with "Invalid private key" or "PEM_read_bio" error
Cause: Private key not formatted correctly in environment variable
Solution:
# Correct format - newlines preserved with \nGITHUB_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA...\n-----END RSA PRIVATE KEY-----"# Incorrect format - actual newlines break shell parsingGITHUB_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----MIIEpAIBAAKCAQEA...-----END RSA PRIVATE KEY-----"# In Vercel environment variables, use actual newlines in the text area# The platform handles escaping automatically
Sources: README.md L314-L367
Refresh this wiki
Last indexed: 23 November 2025 (922b35)
On this page
- GitHub App Configuration
- GitHub App Purpose and Architecture
- GitHub App Integration Architecture
- Creating the GitHub App
- Registration Location
- Basic Configuration Settings
- App Identity
- Description Template
- URL Configuration Mapping
- Permissions Configuration
- Repository Permissions
- Account Permissions
- Permission Enforcement Flow
- OAuth Configuration
- OAuth Settings Checklist
- OAuth Flow and Code Mapping
- Webhook Configuration
- Repository Access Recommendations
- Installation Options
- Security Rationale
- Obtaining GitHub App Credentials
- Credential Acquisition Process
- Credential Mapping Table
- Private Key Handling
- Environment Variable Configuration
- Variable Usage Mapping
- Post-Creation Verification
- Configuration Verification Checklist
- Testing the OAuth Flow
- Managing the GitHub App
- Access URLs
- Ongoing Management Tasks
- Monitoring Installations
- Security Considerations
- Credential Storage
- Access Token Lifespan
- Read-Only Access Model
- Troubleshooting
- Common Configuration Issues
Ask Devin about godeep.wiki-jb
Syntax error in text
mermaid version 11.4.1